from langchain_core.messages import AIMessage, HumanMessage
from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder
from langchain_ollama import ChatOllama

prompt = ChatPromptTemplate.from_messages(
    [
        ("system",
         "你是一个乐于助人的助手，尽你所能回答所有问题。"
         ),
        MessagesPlaceholder(variable_name="messages")
    ]
)

llm = ChatOllama(
    model="llama3",
    temperature=0.5,
)
chain = prompt | llm

result = chain.invoke({
    "messages": [
        HumanMessage("请将这句话从汉语翻译成英文： 你好，我是EasyData智能的AI助手。"),
        AIMessage("Hello, I am the AI assistant of Shuyi Intelligence."),
        HumanMessage("你刚刚说什么？"),
    ]
})

print(result.content)


